const functionMap = {
  state: {
    meetingType: '',
    meetingID: '',
    connectType: 'sfufirst',
    listenPort: window.serverconfig.listenPort,
    signalServer: window.serverconfig.signalServer,
    roomname: '',
    roompwd: '',
    selfID: '',
    isWx: navigator.userAgent.toLowerCase().match(/MicroMessenger/i) == 'micromessenger' // 是否是微信浏览器
  },
  mutations: {
    /** 设置会议类型 */
    setMeetingType (state, type) {
      state.meetingType = type
    },
    /** 会议房间号 */
    setMeetingID (state, meetingID) {
      state.meetingID = meetingID
    },
    /** 设置连接模式 */
    setConnectType (state, type) {
      state.connectType = type
    },
    /** 设置房间名 */
    setRoomname (state, item) {
      state.roomname = item
    },
    /** 设置房间密码 */
    setRoomPwd (state, item) {
      state.roompwd = item
    },
    /** 自己的peerid */
    setSelfID (state, id) {
      state.selfID = id
    }
  },
  actions: {
    async isSupports() {
      var e = window.RTCPeerConnection || window.mozRTCPeerConnection || window.webkitRTCPeerConnection,
          t = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.msGetUserMedia || navigator.mozGetUserMedia || navigator.mediaDevices && navigator.mediaDevices.getUserMedia,
          n = window.WebSocket
      var supportsRTC = !!e && !!t && !!n
      return Promise.resolve(supportsRTC)
    }
  }
}

export default functionMap